﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TreatmentInformationDisclosureDomainService.cs" company="ELEN 7045 GROUP II">
//   
// </copyright>
// <summary>
//   The treatment information disclosure domain service
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Domain.StudyDefinition.Services
{
    #region

    using System;
    using System.Collections.Generic;
    using System.Linq;

    using Domain.StudyDefinition.Contracts.DomainServices;
    using Domain.StudyDefinition.Contracts.Repositories.Treatments;
    using Domain.StudyDefinition.Entities;

    #endregion

    /// <summary>
    /// The treatment information disclosure domain service
    /// </summary>
    public class TreatmentInformationDisclosureDomainService: ITreatmentInformationDisclosureDomainService
    {
        #region Constants and Fields

        /// <summary>
        /// The treatment repository instance.
        /// </summary>
        private readonly ITreatmentRepository treatmentRepositoryInstance;

        #endregion

        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="TreatmentInformationDisclosureDomainService"/> class.
        /// </summary>
        /// <param name="treatmentRepository">
        /// The treatment repository.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// </exception>
        public TreatmentInformationDisclosureDomainService(ITreatmentRepository treatmentRepository)
        {
            if (treatmentRepository == null)
            {
                throw new ArgumentNullException("treatmentRepository");
            }

            this.treatmentRepositoryInstance = treatmentRepository;
        }

        #endregion

        #region Implemented Interfaces

        #region ITreatmentInformationDisclosureDomainService

        /// <summary>
        /// Gets all Treatment.
        /// </summary>
        /// <returns>
        /// A list of Treatment
        /// </returns>
        public List<Treatment> GetAllTreatment()
        {
            return this.treatmentRepositoryInstance.Get().ToList();
        }

        /// <summary>
        /// Gets all treatments without subject groups.
        /// </summary>
        /// <returns>
        /// A list of treatments
        /// </returns>
        public List<Treatment> GetAllTreatmentsWithoutSubjectGroups()
        {
            return this.treatmentRepositoryInstance.Get(t => t.SubjectGroups == null).ToList();
        }

        #endregion

        #endregion
    }
}